package com.buddy.design.pattern._05strategy.promotion;

import java.util.HashMap;
import java.util.Map;

public class PromotionFactory {

    private static Map<String, PromotionStrategy> promotionStrategyMap = new HashMap<>();

    static {
        promotionStrategyMap.put(PromotionKey.CASH, new CashBackPromotion());
        promotionStrategyMap.put(PromotionKey.GROUP, new GroupBuyPromotion());
        promotionStrategyMap.put(PromotionKey.COUPON, new CouponPromotion());
    }

    private static final PromotionStrategy emptyPromotion = new EmptyPromotion();

    private PromotionFactory() {

    }

    public static PromotionStrategy getPromotionStrategy(String promotionKey) {
        PromotionStrategy promotionStrategy = promotionStrategyMap.get(promotionKey);
        return promotionStrategy == null ? emptyPromotion : promotionStrategy;
    }

    private interface PromotionKey {
        String CASH = "CASH";
        String COUPON = "COUPON";
        String GROUP = "GROUP";
    }
}
